package flst.ipiweb.struts.action.administrateur;


import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class NewAdminAction extends Action{
	
	public ActionForward execute(
			ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request, 
			HttpServletResponse response)
			throws Exception {
		
			//On récupère la session
			HttpSession session = request.getSession();
			if(session.getAttribute("login") == null)
			{
				return mapping.findForward("login");
			}
			
			//Titre de la page
			request.setAttribute("pageTitle", "admin.new.title");
			request.setAttribute("mainTitle", "admin.New");
			
			//Activation de l'onglet administrateur
			HashMap<String, String> onglet = new HashMap<String, String>();
			onglet.put("administrateur", "active");
			request.setAttribute("onglet", onglet);
			
			//Legend du formulaire
			request.setAttribute("legend","admin.New");
			
			//Action du formulaire
			request.setAttribute("action", "/new-admin-post");
			
			request.setAttribute("error", session.getAttribute("error"));
			
			return mapping.findForward("new_admin");
		}

	
}
